package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.welfare.common.card.GsTitleCard;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardBean;
import com.huawei.gamebox.service.welfare.gift.bean.GiftCardListBean;
import com.huawei.gamebox.service.welfare.gift.card.BaseGiftCard;
import com.huawei.gamebox.service.welfare.gift.card.VerticalScrollGiftListCard;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.util.ArrayList;
import java.util.List;
import o.cgz;
import o.chy;
import o.chz;
import o.cih;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.epv;
import o.CollectCheck;
import o.exp.j;
import o.eyh;
import o.eys;
import o.fce;
import o.fcs;
import o.ll;

public class VerticalGiftListLineNode extends BaseGiftNode {
    private a ʻ;
    private List<GiftCardListBean> ˏॱ = new ArrayList();
    protected boolean ॱॱ = false;
    private chy ᐝ = null;

    class a extends SafeBroadcastReceiver {
        final /* synthetic */ VerticalGiftListLineNode ˎ;

        private a(VerticalGiftListLineNode verticalGiftListLineNode) {
            this.ˎ = verticalGiftListLineNode;
        }

        public void onReceiveMsg(Context context, Intent intent) {
            String action = intent.getAction();
            if (Logger.ˎ()) {
                Logger.ˏ("VerticalGiftListLineNode", "receive " + action);
            }
            if ("com.huawei.gamebox.refreshBuoyGiftCard".equals(action)) {
                String stringExtra = intent.getStringExtra("refresh.observer.id");
                String stringExtra2 = intent.getStringExtra("refresh.observer.value");
                if (this.ˎ.ˏॱ.size() > 0) {
                    for (GiftCardListBean ˊ : this.ˎ.ˏॱ) {
                        for (GiftCardBean giftCardBean : ˊ.ˊ()) {
                            if (!dof.ॱ(stringExtra) && stringExtra.equals(giftCardBean.ᐝ()) && 2 != giftCardBean.ʼ()) {
                                giftCardBean.ˎ(2);
                                giftCardBean.ˏ(stringExtra2);
                                if (Logger.ˎ()) {
                                    Logger.ˏ("VerticalGiftListLineNode", "refresh GiftsCardList");
                                }
                                eyh.ˏ();
                                return;
                            }
                        }
                    }
                }
            }
        }
    }

    static class c extends fcs {
        private final cgz ॱ;

        c(chy o_chy, cgz o_cgz, int i) {
            super(o_chy, o_cgz, i);
            this.ॱ = o_cgz;
        }

        public void onClick(View view) {
            super.onClick(view);
            if (this.ॱ != null) {
                CardBean ˌ = this.ॱ.ˌ();
                if (ˌ instanceof GiftCardBean) {
                    GiftCardBean giftCardBean = (GiftCardBean) ˌ;
                    eys.ˏ(giftCardBean.ͺˏ(), "FORUMGIFTS", giftCardBean.ॱॱ());
                }
            }
        }
    }

    public VerticalGiftListLineNode(Context context) {
        super(context);
    }

    public void ॱˊ() {
        super.ॱˊ();
        ॱᐝ();
    }

    protected void ॱᐝ() {
        this.ʻ = new a();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.gamebox.refreshBuoyGiftCard");
        ll.ˏ(ContentManager.getInstant().getContext().getApplicationContext()).ˏ(this.ʻ, intentFilter);
        if (Logger.ˎ()) {
            Logger.ˏ("VerticalGiftListLineNode", "registerReceiver");
        }
    }

    protected View ˊ(LayoutInflater layoutInflater) {
        View view = null;
        if (layoutInflater != null) {
            view = (RelativeLayout) layoutInflater.inflate(j.ـ, null);
            if (view != null) {
                int ˎ = ˎ();
                view.setPadding(ˎ, 0, ˎ, 0);
            }
        }
        return view;
    }

    public boolean ॱ() {
        return true;
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        layoutParams.weight = 1.0f;
        int ˏ = ˏ();
        for (int i = 0; i < ˏ; i++) {
            cih verticalScrollGiftListCard = new VerticalScrollGiftListCard(this.ॱ);
            LinearLayout linearLayout = (LinearLayout) this.ˊ.inflate(j.ˋˊ, null);
            GsTitleCard ʼ = ʼ();
            View ॱ = ॱ(this.ˊ);
            if (ॱ != null) {
                ʼ.ˏ(ॱ);
                verticalScrollGiftListCard.ˊ(ʼ);
                linearLayout.addView(ॱ);
            }
            View linearLayout2 = new LinearLayout(this.ॱ);
            LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -2);
            linearLayout2.setOrientation(1);
            linearLayout2.setLayoutParams(layoutParams2);
            verticalScrollGiftListCard.ˏ(linearLayout2);
            linearLayout.addView(linearLayout2);
            ˊ(verticalScrollGiftListCard);
            viewGroup.addView(linearLayout, layoutParams);
        }
        return true;
    }

    protected boolean ॱॱ() {
        return true;
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        int ˏ = ˏ();
        this.ˏ = o_chz.ˏ;
        for (int i = 0; i < ˏ; i++) {
            cih ˎ = ˎ(i);
            if (ˎ instanceof VerticalScrollGiftListCard) {
                VerticalScrollGiftListCard verticalScrollGiftListCard = (VerticalScrollGiftListCard) ˎ;
                CardBean ˋ = o_chz.ˋ(i);
                if (ˋ instanceof GiftCardListBean) {
                    ˋ.ˋˋ(String.valueOf(this.ˏ));
                    GiftCardListBean giftCardListBean = (GiftCardListBean) ˋ;
                    this.ˏॱ.add(giftCardListBean);
                    List ˊ = giftCardListBean.ˊ();
                    if (CollectCheck.isEmpty(ˊ)) {
                        ˎ.ˉ().setVisibility(8);
                    } else {
                        int size = ˊ.size();
                        this.ॱॱ = ˋ.ॱㆍ();
                        if (ॱॱ() && epv.ˏॱ(this.ॱ)) {
                            ॱ(verticalScrollGiftListCard, size, 2);
                        } else {
                            ˊ(verticalScrollGiftListCard, size);
                        }
                        ˎ.ˏ(ˋ);
                        ˎ.ˉ().setVisibility(0);
                    }
                } else {
                    ˎ.ˉ().setVisibility(8);
                }
            }
        }
        return true;
    }

    protected GsTitleCard ʼ() {
        return new GsTitleCard(this.ॱ);
    }

    public void ˋ(chy o_chy) {
        this.ᐝ = o_chy;
        for (int i = 0; i < ˊॱ(); i++) {
            VerticalScrollGiftListCard verticalScrollGiftListCard = (VerticalScrollGiftListCard) ˊ(i);
            if (verticalScrollGiftListCard != null) {
                verticalScrollGiftListCard.ˊ().ॱ(o_chy);
                for (int i2 = 0; i2 < verticalScrollGiftListCard.ˋ(); i2++) {
                    cgz ˊ = verticalScrollGiftListCard.ˊ(i2);
                    View view = null;
                    if (ˊ != null) {
                        view = ˊ.ˉ();
                    }
                    if (view != null) {
                        view.setOnClickListener(new c(o_chy, ˊ, 0));
                    }
                }
            }
        }
    }

    public void ॱˎ() {
        super.ॱˎ();
        ॱˋ();
    }

    private void ॱˋ() {
        if (this.ʻ != null) {
            ll.ˏ(ContentManager.getInstant().getContext().getApplicationContext()).ˋ(this.ʻ);
            if (Logger.ˎ()) {
                Logger.ˏ("VerticalGiftListLineNode", "unRegisterReceiver");
            }
        }
    }

    protected BaseGiftCard ˏ(boolean z) {
        BaseGiftCard o_fce = new fce(this.ॱ, z, ʻ());
        o_fce.ॱ(true);
        return o_fce;
    }

    protected chy ᐝ() {
        return this.ᐝ;
    }
}
